package cn.qxq1.springevent.controller;

import cn.qxq1.springevent.event.MyEvent;
import cn.qxq1.springevent.event.MyEventPublisher;
import cn.qxq1.springevent.event.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    private MyEventPublisher myEventPublisher;

    @RequestMapping("/t1")
    public String t1() {
        User user = new User();
        user.setAge(12);
        user.setName("Lily");
        user.setEmail("123456@qq.com");
        MyEvent<User> event = new MyEvent<>(user);
        myEventPublisher.publish(event);
        System.out.println("test func is executed....");
        return "success";
    }
}
